package com.cxb.springboot.controller;

import com.cxb.springboot.service.AsyncService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.CompletableFuture;

/**
 * @Classname AsyncController
 * @Date 2023/8/18 22:38
 * @Created by Administrator
 * @Description TODO
 */
@Slf4j
@RestController
@RequestMapping("/async")
@Api(value = "AsyncController", tags = "异步任务")
public class AsyncController {

    @Autowired
    private AsyncService asyncService;

    @GetMapping
    public CompletableFuture<String> asyncMethod() {
        return asyncService.asyncMethod();
    }

    @GetMapping("/task-pool")
    public String taskPool() {
        asyncService.executeAsyncTask();
        return "success";
    }
}
